﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Transactions {
    import Classes.*;
    import Display.*;
    import Init.*;

    public class TSetCurrentThemes extends TWorldLoad {

        private var m_themeCollectionName:String;
        private var m_enable:Boolean;

        public function TSetCurrentThemes(_arg1:String, _arg2:Boolean){
            var _local4:String;
            var _local5:String;
            super(Global.player.uid);
            this.m_themeCollectionName = _arg1;
            this.m_enable = _arg2;
            var _local3:Item = Global.gameSettings.getItemByName(this.m_themeCollectionName);
            if (_local3.endDate <= GameSettingsInit.getCurrentTime()){
                _local4 = ZLoc.t("Items", (_local3.name + "_friendlyName"));
                _local5 = ZLoc.t("Dialogs", "CatalogItemExpired", {itemName:_local3.localizedName});
                UI.displayMessage(_local5, GenericPopup.TYPE_OK);
            } else {
                if (_local3.cost > 0){
                    Global.player.gold = (Global.player.gold - _local3.cost);
                } else {
                    if (_local3.cash > 0){
                        Global.player.cash = (Global.player.cash - _local3.cash);
                    } else {
                        GlobalEngine.msg((this.m_themeCollectionName + " cost nothing, make sure this is intentional behavior."));
                    };
                };
            };
        }
        override public function perform():void{
            signedCall("WorldService.setCurrentThemes", this.m_themeCollectionName, this.m_enable);
        }
        override protected function onComplete(_arg1:Object):void{
            super.onComplete(_arg1);
            UI.refreshCatalog(true);
        }

    }
}//package Transactions 
